package com.hxd.otc.module.wallet.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.hxd.otc.R;
import com.hxd.otc.utils.ResourceUtil;


/**
 * Created by alphabet on 2018/5/30.
 */

public class HeaderPagerAdapter extends PagerAdapter {

    @Override
    public int getCount() {
        return 2;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View view = LayoutInflater.from(container.getContext()).inflate(R.layout.item_wallet_header_vp, container, false);
        ImageView ivTop = view.findViewById(R.id.iv_top);
        TextView tvAccount = view.findViewById(R.id.tv_account);
        switch (position) {
            case 0:
                ivTop.setBackgroundResource(R.mipmap.icon_wallet_header_bg_of_otc);
                tvAccount.setText(ResourceUtil.getString(R.string.otc_account));
                break;
            case 1:
                ivTop.setBackgroundResource(R.mipmap.icon_wallet_header_bg_of_common);
                tvAccount.setText(ResourceUtil.getString(R.string.normal_account));
                break;
        }
        container.addView(view);
        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(((View) object));
    }
}
